# Maintainer: Anatol Pomozov <anatol.pomozov@gmail.com>

pkgname=stlink
pkgver=1.7.0
pkgrel=1
pkgdesc='Firmware programmer for STM32 STLINK v1/v2 protocol'
arch=(loong64 x86_64)
url='https://github.com/texane/stlink'
license=(BSD)
# Add support for gtk3-based GUI
depends=(libusb)
makedepends=(cmake gtk3)
optdepends=('gtk3: GUI application')
install=stlink.install
source=($pkgname-$pkgver.zip::https://github.com/texane/stlink/archive/v$pkgver.zip)
sha256sums=('dd2fde56c701b9084f6c60c5d2549673150b596f06cffe1334f498013a97f0e1')

build() {
  cd stlink-$pkgver
  cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr \
        -DSTLINK_UDEV_RULES_DIR=/usr/lib/udev/rules.d \
        -DSTLINK_MODPROBED_DIR=/usr/lib/modprobe.d
  make
}

package() {
  cd stlink-$pkgver

  make DESTDIR="$pkgdir" install

  install -Dm644 LICENSE.md "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
  rm "$pkgdir"/usr/lib/libstlink.a
}
